package extractor;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TitleExtractor {
	private Pattern patternTag;
	private Matcher matcherTag;

	private static final String HTML_TITLE_PATTERN = "(?i)<title>(.+?)</title>";

	public TitleExtractor() {
		patternTag = Pattern.compile(HTML_TITLE_PATTERN);
	}

	public String grabTitle(final String html) {
		matcherTag = patternTag.matcher(html);
		while (matcherTag.find()) {
			return matcherTag.group(1);
		}

		return null;
	}
}
